const db = require("../../lib/db");

// 查询是否注册
exports.isRegister = () => {
    let _sql = `SELECT count(*) AS count FROM users`;
    return db.queryWithPool(_sql);
  };
  
  //管理员注册
  exports.insertUser = (value) => {
    let _sql = `INSERT INTO users set ?`;
    return db.queryWithPool(_sql, value);
  };

  //查询用户是否存在
  exports.findUser = (name) => {
    let _sql = `SELECT * FROM users WHERE user_name = ?`;
    return db.queryWithPool(_sql, [name]);
  };
  
  //管理员登录
  exports.signin = (email) => {
    let _sql = `SELECT * FROM users WHERE email = ?`;
    return db.queryWithPool(_sql, [email]);
  };